home *** CD-ROM | disk | FTP | other *** search
- Path: news.ichange.com!newsmaster
- From: jshute@connect.reach.net (Jeff Shute)
- Newsgroups: comp.lang.c++
- Subject: What's so bad about global variables?
- Date: Sat, 10 Feb 1996 23:49:29 -0500
- Organization: The Lattan Empire Gift Shop
- Message-ID: <4fjtga$a8s@ias2.ichange.com>
- NNTP-Posting-Host: 204.50.58.65
- X-Newsreader: Forte Free Agent 1.0.82
-
-
- Why do programmers treat like global variables as if they are the
- single most evil thing you can possibly do in a C program?
-
- In reading through a programming book, I came across a program that
- needed to use random numbers. Instead of just using the C library
- functions, they developed their own class for random numbers. Their
- justification - srand and rand will result in the creation of a global
- variable, and all good programmers know that global variables must be
- avoided.
-
- To me, this seems a little silly. I don't see what the problem is
- with global variables, especially when they can be hidden using
- static. Is it really that important to avoid global variables?
-
- ---
- Jeff Shute
- jshute@connect.reach.net
-
-